import Vue from 'vue';
import VueRouter from 'vue-router';

import StockQuery from '@/components/back/Stock/QueryAll';
import Audit from '@/components/back/Stock/Audit';
import Login from '@/components/Login.vue';
import PurchaseOrders from "@/components/back/Purchase/PurchaseOrders";
import PurAudit from "@/components/back/Purchase/PurAudit";
import PurAuditDetail from "@/components/back/Purchase/PurAuditDetail";
import PurDetail from "@/components/back/Purchase/PurDateil";
import PurQuery from "@/components/back/Purchase/PurQuery";
import PurInStock from "@/components/back/inStock/PurInStock";
import InStockAudit from "@/components/back/inStock/InStockAudit";
import InAuditDetail from "@/components/back/inStock/InAuditDetail";
import QueryCell from "@/components/back/Cell/QueryCell";
import OrderQuery from'@/components/back/orders/QueryAll';
import OutOrder from "@/components/back/outStock/OutOrder";
import OutStockDetail from "@/components/back/outStock/OutStockDetail";
import OutAudit from "@/components/back/outStock/OutAudit";
import OutAuditDetail from "@/components/back/outStock/OutAuditDetail";
import Home from '@/components/Home.vue';
import welcomeelcome from '@/components/welcome.vue';
import Welcome from '@/components/welcome.vue';
import Users from '@/components/user/users.vue'
import Rights from '@/components/power/Rights.vue'
import Role from '@/components/power/Role.vue'

import Product from '@/components/back/Product/Product.vue';
import ProductType from '@/components/back/Product/ProductType.vue';
import SelectComments from "@/components/comments/SelectCorments.vue";
import SelectCommentsById from "@/components/comments/SelectCommentsById.vue";
import CommercialTenant from '@/components/comments/CommercialTenant.vue';
import CommercialTenantAudit from '@/components/comments/CommercialTenantAudit.vue';
import CommercialTenantById from '@/components/comments/CommercialTenantById.vue';
import Supplier from '@/components/comments/Supplier.vue';
import SupplierAudit from '@/components/comments/SupplierAudit.vue';
import SupplierById from '@/components/comments/SupplierById.vue';

Vue.use(VueRouter)

const router=new VueRouter({
	routes: [
		//主页组件
		{path:'/home',
			component:Home,
			redirect:'/welcome',
			children:[
				{path:'/product' ,component:Product },
				{path:'/productType' ,component:ProductType },
				{path:'/welcome', component:Welcome},
				//用户管理
				{path:'/users',component:Users},
				//用户查询
				{path: '/selectComments', component: SelectComments},
				// //根据ID查询用户
				{path: '/selectCommentsById', component: SelectCommentsById},
				//商户查询
				{path: '/commercialTenant', component: CommercialTenant},
				//商户审核
				{path: '/commercialTenantAudit', component: CommercialTenantAudit},
				//根据id查询商户
				{path: '/commercialTenantById',component: CommercialTenantById},
				//供应商查询
				{path: '/supplier', component: Supplier},
				//供应商审核
				{path: '/supplierAudit', component: SupplierAudit},
				//根据ID查询供应商
				{path: '/supplierById',component: SupplierById},
				//出库审核详情·
				{path: "/outAuditDetail",component: OutAuditDetail},
				//出库审核
				{path: "/outAudit",component: OutAudit},
				//添加出库详情
				{path: "/outDetail",component: OutStockDetail},
				//出库发货
				{path: "/outOrder",component: OutOrder},
				//动态库存查询
				{path: "/cellQuery",component: QueryCell},
				//所有订单
				{path: "/OrderQuery",component: OrderQuery},
				//入库审核详情
				{path: "/InAuditDetail",component: InAuditDetail},
				//入库审核
				{path: "/InAudit",component: InStockAudit},
				//采购收货入库
				{path: "/PurInStock",component: PurInStock},
				//查询所有采购单
				{path: "/PurQuery",component: PurQuery},
				//采购单详情
				{path:'/PurDetail' ,component:PurDetail },
				//仓库审核
				{path:'/Audit' ,component:Audit },
				//采购单审核
				{path:'/PurAuditDetail' ,component:PurAuditDetail },
				//查询采购单审核状态
				{path:'/PurAudit' ,component:PurAudit},
				//采购单申请
				{path:'/PurOrder',component: PurchaseOrders},
				//仓库主页面
				{path:'/stockQuery', component:StockQuery,},
			] },
		{path:'/home',component:Home,redirect:'/welcome',
		children:[
			{path:'/welcome', component:Welcome},
			{path:'/users',component:Users},
			{path:'/rights',component:Rights},
			{path:'/role',component:Role}

		] },
		{path:'/Audit' ,component:Audit },

		{
			path:'/stockQuery',
			component:StockQuery,
			// children:[
			// 	{ path: '/welcome',component:Welcome},
			// 	{ path: '/users',component:Users},
			// 	{ path: '/storeCell',component:StoreCell},
			// 	{ path: '/storeCellFuheList',component:StoreCellFuheList},
			// 	{ path: '/storeCellunmake',component:StoreCellunmake},
			// ]
		},
		// 重定向
	    { path: '/', redirect: '/login' },
		 // 登录组件
	    { path: '/login', component:Login  }



	]
})

// 全局导航守卫
// router.beforeEach((to, from, next)=>{
//     // 如果访问的路由是/login, 不判断直接放行
//     if(to.path === '/login')
//         return next()
//     // 如果访问的路由不是/login, 判断是否有token
//     // 从sessionStorage中获取token
//     const token = window.sessionStorage.getItem('token')
//     if(!token)
//         return next('/login')
//     next()
// })

export default router